<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>确认付款</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="__PUBLIC__/static/agent/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__PUBLIC__/static/agent/css/wallet.css" />
		<style type="text/css">
			.fuk_conbox{background: none; padding: 5% 2%;}
			.fuk_ctimg{width: 40%;}
			.ffuk_prinum{font-size: .9rem; margin: 1.8rem 0 .2rem;}
			#sale_price{font-size: 2rem; line-height: 35px; text-align: center; margin-top: 1.2rem;}
			.label{float: left; line-height: 35px;}
			.pay_spnum{ width: 100px; padding: 0 30px;}
			.mui-numbox [class*=btn-numbox]{width: 30px;}
		</style>
	</head>
	
	<style>
		#t1{
			color: #1caceb;
		}
		.cz{
			display: inline;
			color: white;
			background-color: #1caceb;
			display: block;
		    float: right;
		    font-size: .8rem;
		    width: 25%;
		    text-align: center;
		    height: 1.8rem;
		    line-height: 1.8rem;
		    border-radius: 12px;
		    margin-top:-.2rem;
		}
	</style>

	<body style="background-color: white;">
		<form id="my_form" class="layui-form update_form" action="{:url('shop/topay')}" method="post">
			<input type="hidden" name="good_id" value="{$goods['id']}" />
		<div class="mui-content qrfuk_content" style="background: white;">
			<div class="fuk_conbox">
				<div class="fuk_ctop">
					<div class="fuk_ctimg" style="text-align: center;"><img id='store_thum' style="width: 100px;height:80px;" src="{$goods['thumb']}">
					<div class="fuk_spnam">{$goods['goods_name']}</div>
				</div>
				<div id="sale_price" style="text-align:inherit;">
					<span class="shopinf_glj" style="float: left;font-size: .75rem;line-height: 25px;">鼓励金折扣价</span><span style="margin-left: 20%;">¥<span id="price">0</span></span>
				</div>
				
				<div class="ffuk_prinum clearfix" style="margin-left:25%">
					<div class="label" style="color: #8c8787;">数量：</div>
					<div class="mui-numbox pay_spnum">
						<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
						<input class="mui-input-numbox" type="number" onchange="change(this)" id="buy_number" name="nums" value="1">
						<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
					</div>
				</div>
				<button type="submit" class="qrfuk_btn" onclick="return check_num()" id='qrfuk_btn'>确认付款</button>
			</div>
			 
			<div style="text-align: center; color: red;padding-top: 20px;"><span id="t1"></span><a href="/index/member/glj_cz" class='cz'>去充值</a></div>
		</div>
		<input type="hidden" name="goods_id" value="{$goods.id}">
		</form>
		{include file="shop/footer" /}
	</body>

</html>
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
<script src="__PUBLIC__/static/js/mui.min.js"></script>
<script src="__PUBLIC__/static/layui/layui.all.js"></script>
<script> 
	var score =0;
	var dk=0;
	var gd_price=0;
	function change(obj){
		if($(obj).val()<=1){
			$(obj).val(1);
		}
		var buy_number = parseFloat($(obj).val());
		var much=buy_number*gd_price;
		var dk_score = dk*buy_number;
		var bt=dk_score-score;
		if(score<=0){
			$("#price").text(gd_price);
			$('#t1').text("购买鼓励金可抵扣"+dk_score+"元");
		}else{
			if(bt>0){
				much=much-score;
				var bd=dk_score-score;
				$('#t1').text("购买鼓励金可再抵扣"+bd+"元");
			}else{
				much=much-dk_score;
				$('#t1').text("鼓励金剩余 "+score);
			}
		}
		$("#del").text(buy_number*gd_price);
		$("#price").text(much);
		
		
	}
	
	function check_num(){
		var goods_num ="{$goods.stock}";
		var pay_num = $('#buy_number').val();
		if(parseInt(goods_num)<parseInt(pay_num)){
			layer.msg('库存不足');
			return false;
		}
		
	}

	$(function(){
		score = parseFloat("{$score}");
		dk=parseFloat("{$goods.dk_price}");
		gd_price=parseFloat("{$goods.sale_price}");
		var dk_score = dk - score;
		if(score<=0){
			$("#price").text(gd_price);
			$('#t1').text("购买鼓励金可抵扣"+dk+"元");
		}else{
			if(dk_score>0){
				$("#price").text(gd_price-score);
				$('#t1').text("购买鼓励金可再抵扣"+dk_score+"元");
			}else{
				$("#price").text(gd_price-dk);
				$('#t1').text("鼓励金剩余 "+score);
			}
		}
		
	});
	
</script>